﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Pigmalion.UIWF.Almacen;

namespace Pigmalion.UIWF
{
    public partial class MainMDI : Form
    {
        ICommand refreshCommand;
        ICommand newCommand;
        ICommand editCommand;
        ICommand deleteCommand;
        Invoker _invoker;

        public MainMDI()
        {
            InitializeComponent();
        }

        private void productosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ProductoView productoView = new ProductoView();
            productoView.MdiParent = this;
            productoView.Show();


        }

        private void refrescarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form ventana = ActiveMdiChild;

            refreshCommand = new RefreshCommand(ventana);

            _invoker = new Invoker(refreshCommand);
            _invoker.Execute(); 

        }

        private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form ventana = ActiveMdiChild;

            deleteCommand = new DeleteCommand(ventana);

            _invoker = new Invoker(deleteCommand);
            _invoker.Execute(); 

        }

        private void nuevoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form ventana = ActiveMdiChild;

            if (ventana !=null)
            {
                newCommand = new NewCommand(ventana);

                _invoker = new Invoker(newCommand);
                _invoker.Execute();
            }
        }

        private void editarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form ventana = ActiveMdiChild;

            if (ventana !=null)
            {
                editCommand = new EditCommand(ventana);

                _invoker = new Invoker(editCommand);
                _invoker.Execute();
            }
        }

        private void salirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void clientesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ClienteView clienteView = new ClienteView();
            clienteView.MdiParent = this;
            clienteView.Show();
        }

        private void crearPedidoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            PedidoMttoView pedidoMttoView = new PedidoMttoView();
            pedidoMttoView.MdiParent = this;
            pedidoMttoView.Show();
        }
    }
}
